import java.math.BigInteger;
public class factorial {

    //计算一个数的阶乘
    public static BigInteger fun_fact(int order) {
        BigInteger order_factorial = new BigInteger("1");
        for (int iter = 1; iter <= order; iter++) {
            order_factorial = order_factorial.multiply(BigInteger.valueOf(iter));
        }
        return order_factorial;
    }

    public static void main(String arg[]){
        BigInteger ans = new BigInteger("0");
        for (int iter=1;iter<=30;iter++){
            ans=ans.add(fun_fact(iter));
        }
        System.out.println(ans);
    }
}